package mysql

import "gorm.io/gorm"

type Goods struct {
	gorm.Model
	UserId      int64  `gorm:"type:int(11);not null;comment:用户Id"`
	GoodsTitle  string `gorm:"type:varchar(20);comment:商品标题"`
	GoodsPrice  int64  `gorm:"type:int(11);comment:商品价格"`
	GoodsStock  int64  `gorm:"type:int(11);comment:商品库存"`
	GoodsCover  string `gorm:"type:varchar(200);comment:商品封面"`
	GoodsStatus int64  `gorm:"type:tinyint(1);default:1;comment:状态:1:待出售,2:上架,3:下架"`
}

func (g *Goods) Create() error {
	return Db.Create(&g).Error
}
func (g *Goods) GoodsGetInfo() error {
	return Db.Where("id = ?", g.ID).Limit(1).Find(&g).Error
}
